package base.BeD.Fifth;

import static net.mindview.util.Print.*;

public class E05_BitwiseOperators2 {
	private static void toBinaryString(int i){
		char[] nums = new char[32];
		int maxlong = 32;
		do{
			nums[--maxlong] = (i&0x01) != 0 ? '1' : '0';
			i>>>=1;
		}while(i !=0);
		for(int m =maxlong; m<32; m++){
			System.out.print(nums[m]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		int i1 = 0xaaaaaaaa;
		int i2 = 0x55555555;
		printnb("i1 = "); toBinaryString(i1);
		printnb("i2 = "); toBinaryString(i2);
		printnb("~i1 = "); toBinaryString(~i1);
		printnb("~i2 = "); toBinaryString(~i2);
		printnb("i1 & i1 = "); toBinaryString(i1 & i1);
		printnb("i1 | i1 = "); toBinaryString(i1 | i1);
		printnb("i1 ^ i1 = "); toBinaryString(i1 ^ i1);
		printnb("i1 & i2 = "); toBinaryString(i1 & i2);
		printnb("i1 | i2 = "); toBinaryString(i1 | i2);
		printnb("i1 ^ i2 = "); toBinaryString(i1 ^ i2);
	}
}
